{% extends 'rbac/base.html' %}
{% block addcss %}
    <link href="/static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    {% if action_dict %}
        <link href="/static/css/plugins/select2/select2.min.css" rel="stylesheet">
        <link href="/static/css/plugins/iCheck/custom.css" rel="stylesheet">
    {% endif %}
    <style>
        .table-size {
            font-size: 13px;
        }

        .w {
            padding-bottom: 10px;
        }

        .screen {
            margin: 10px 15px;
        }

        .whole {
            font-weight: bold;
            font-size: 14px;
            line-height: 14px;
            padding-top: 9px;
        }

        .others a {
            margin-right: 5px;
        }
    </style>
{% endblock %}
{% block content %}
    {% load menu %}
    {% breadcrumb request %}

    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>
                            {% with request.breadcrumb|last as last %}
                                {{ last.title }}
                            {% endwith %}
                        </h5>
                        <div class="ibox-tools">
                        </div>
                    </div>


                    <div class="ibox-content">
                        {% if search_group_row %}
                            <div class="panel-body" style="padding: 10px 0">
                                <div class="panel-group" id="accordion">

                                    <div class="panel panel-default">
                                        <div class="panel-heading">
                                            <h5 class="panel-title">
                                                <a data-toggle="collapse" data-parent="#accordion"
                                                   href="#collapseOne"><i
                                                        class="fa fa-tags"></i>快速筛选项目</a>
                                            </h5>
                                        </div>
                                        <div id="collapseOne" class="panel-collapse collapse in show">
                                            <div class="panel-body">
                                                {% for row in search_group_row %}
                                                    {% for item in row %}
                                                        {{ item|safe }}
                                                    {% endfor %}
                                                {% endfor %}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        {% endif %}
                        {% if search_list %}
                            <form method="get" class="form-inline float-right ">
                                <div class="form-group">
                                    <input type="text" placeholder="请输入搜索..." name="q" id="search-value"
                                           class="form-control" value="{{ search_value }}">
                                </div>
                                <button class="btn btn-success" type="submit" style="margin-left: 10px"><i
                                        class="fa fa-search"></i>搜索
                                </button>
                            </form>
                        {% endif %}

                        {% if action_dict %}
                            <form method="post" class="">
                        {% endif %}

                        {% csrf_token %}
                        <div class="w form-inline">
                            {% if action_dict %}
                                <select class="mutli_select form-control col-md-2" name="action">
                                    <option></option>
                                    {% for func_name,func_val in action_dict.items %}
                                        <option value="{{ func_name }}">{{ func_val }}</option>
                                    {% endfor %}
                                </select>
                                <input class="btn btn-primary" type="submit" style="margin: 0 10px" value="执行"/>
                            {% endif %}
                            {% if add_btn %}
                                {{ add_btn|safe }}
                            {% endif %}
                        </div>
                        <div class="table-responsive">
                            {% if error %}
                                {{ error|safe }}
                            {% endif %}
                            <table class="table table-striped table-bordered table-hover text-center table-size">
                                <thead>
                                <tr>
                                    {% for item in table_head %}
                                        <th>{{ item }}</th>
                                    {% endfor %}
                                </tr>
                                </thead>
                                <tbody>
                                {% for row in table_body %}
                                    <tr>
                                        {% for data in row %}
                                            <td>{{ data }}</td>
                                        {% endfor %}
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                        {% if action_dict %}
                            </form>
                        {% endif %}
                        {#                    分页表#}
                        <div class="col-sm-12 clearfix">
                            <ul class="pagination float-right">
                                {{ pager.page_html|safe }}
                            </ul>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block addjs %}
    <script src="/static/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script src="/static/rbac/del.js"></script>
    {% if action_dict %}
        <script src="/static/js/plugins/iCheck/icheck.min.js"></script>
        <script src="/static/js/plugins/select2/select2.full.min.js"></script>
        <script>
            $(document).ready(function () {
                $(".mutli_select").select2({
                    placeholder: "请选择批量操作",
                    allowClear: true
                });
                $('.i-checks').iCheck({
                    checkboxClass: 'icheckbox_square-green',
                });

                $("#check_all ").siblings().click(function () {
                    if ($('#check_all').parent().hasClass('checked')) {
                        $('.i-checks div[class!="icheckbox_square-green checked"]').slice(1,).children('.iCheck-helper').click();
                    } else {
                        $('.i-checks div[class*="checked"]').children('.iCheck-helper').click();
                    }
                });
            })
        </script>
    {% endif %}

{% endblock %}
